define([
    'static',
    '../../../framework/bean/admanage',
    './table/adjustPrice',
    './table/editAd',
    './table/openAdchart',
    './table/editInnovate',
    './table/subdivideData'
], function (CONST,
             admanageModel,
             AdjustPrice,
             EditAd,
             OpenAdchart,
             EditInnovate,
             SubdivideData) {
    extend(Main, Combine);

    function Main() {
        var _this = this;
        var _super = arguments.callee.parent;
        var tre;
        var queryParams;
        var header = [
            ["name", I18N.getText('management', 'name')],
            ["campaignName", I18N.getText('management', 'campaignName')],
            ["status", I18N.getText('management', 'status')],//状态
            ["todaySpent", I18N.getText('management', 'todaySpent')], //今日花费
            ["spent", I18N.getText('management', 'spent')], //总花费
            ["clicks", I18N.getText('management', 'clicks')], //点击
            ["ctr", I18N.getText('management', 'ctr')], //点击率
            ["cpc", I18N.getText('management', 'cpc')], //成本
            ["purchase", I18N.getText('management', 'purchase')], //转化率
            ["purchaseR", I18N.getText('management', 'purchaseR')], //转化率
            ["cps", I18N.getText('management', 'cps')], //转化率
            ["salesAmount", I18N.getText('management', 'salesAmount')], //转化率
            ["roi", I18N.getText('management', 'roi')], //转化率
            ["cart", I18N.getText('management', 'cart')],//加入购物车
            ["cartR", I18N.getText('management', 'cartR')], //出价
            ["gaClicks", I18N.getText('management', 'gaClicks')], //出价
            ["gaCart", I18N.getText('management', 'gaCart')],//出价
            ["gaPays", I18N.getText('management', 'gaPays')], //出价
            ["gaOrderAmount", I18N.getText('management', 'gaOrderAmount')], //出价
            ["gaCartR", I18N.getText('management', 'gaCartR')], //出价
            ["gaCpa", I18N.getText('management', 'gaCpa')], //出价
            ["gaCpc", I18N.getText('management', 'gaCpc')], //出价
            ["gaOrderPrice", I18N.getText('management', 'gaOrderPrice')], //出价
            ["gaRoi", I18N.getText('management', 'gaRoi')], //出价
            ["gaCr", I18N.getText('management', 'gaCr')], //出价
            ["budget", I18N.getText('management', 'budget')], //预算
            ["price", I18N.getText('management', 'price')], //出价
            ["createdUtcTime", I18N.getText('management', 'createTime')]  //创建时间
        ];
        this.init = function () {
            var bool = false;
            _this._DOM = $("[data-com='table']");
            _this.adManageTable = '.ndp-treable-wrapper'; // 表格选择器,避免大量的写重复内容
            _this.$adManageTable = null;
            _this.sortCol = '15'; //默认使用创建时间排序
            _this.sortType = 'down';
            _this.setTimeoutId = 0; //默认定时器
            this.initFilterData();
            _this.render();
            _this.event();
            _this.filterEvent();
        };

        this.getFilterHeader = function () {
            var returnHeader = [{ label: '' }], filterHeader = [],keyHeader = [];
            //加入filter
            $("#tableFilter").find('input[type=checkbox]:checked').each(function () {
                filterHeader.push($(this).val());
                keyHeader.push($(this).attr("data-key"));
            });
            for (var i = 0; i < filterHeader.length; i++) {
                returnHeader.push({
                    label: filterHeader[i]
                });
            }
            window.localStorage.setItem("tableHeader",keyHeader.join());
            return returnHeader;
        }
        this.getInitSortNums = function(){
            var returnArr = [];
            var localHeader = window.localStorage.getItem("tableHeader");
            var headerArr = localHeader.split(",");
            for(var i = 0;i<=headerArr.length;i++){
                if(i>3){
                    returnArr.push(i + ''); //前面4个固定值，不排序
                }
            }
            return returnArr;
        }
        this.initFilterData = function () {
            var _html = "",keyHeader = [];
            var localHeader = window.localStorage.getItem("tableHeader");
            if(localHeader == null){
                $.each(header, function (i, obj) {
                    if($.inArray(obj[0],["name","campaignName","status"]) == -1){
                        _html += '<li class="drop-one-item checkbox-item"><span title="' + obj[1] + '">' + obj[1] + '</span><input type="checkbox" data-key="'+ obj[0] +'" value="' + obj[1] + '" checked="checked"></li>';
                    }else{
                        _html += '<li class="drop-one-item checkbox-item"><span title="' + obj[1] + '">' + obj[1] + '</span><input type="checkbox" data-key="'+ obj[0] +'" value="' + obj[1] + '" checked="checked" disabled ></li>';
                    }
                    keyHeader.push(obj[0]);
                });
                window.localStorage.setItem("tableHeader",keyHeader.join());
            }else{
                var localHeaderArr = localHeader.split(',');
                $.each(header, function (i, obj) {
                    if($.inArray(obj[0],localHeaderArr) == -1){
                        if($.inArray(obj[0],["name","campaignName","status"]) == -1){
                            _html += '<li class="drop-one-item checkbox-item"><span title="' + obj[1] + '">' + obj[1] + '</span><input type="checkbox" data-key="'+ obj[0] +'" value="' + obj[1] + '"></li>';
                        }else{
                            _html += '<li class="drop-one-item checkbox-item"><span title="' + obj[1] + '">' + obj[1] + '</span><input type="checkbox" data-key="'+ obj[0] +'" value="' + obj[1] + '" disabled ></li>';
                        }
                    }else{
                        if($.inArray(obj[0],["name","campaignName","status"]) == -1){
                            _html += '<li class="drop-one-item checkbox-item"><span title="' + obj[1] + '">' + obj[1] + '</span><input type="checkbox" data-key="'+ obj[0] +'" value="' + obj[1] + '" checked="checked"></li>';
                        }else{
                            _html += '<li class="drop-one-item checkbox-item"><span title="' + obj[1] + '">' + obj[1] + '</span><input type="checkbox" data-key="'+ obj[0] +'" value="' + obj[1] + '" checked="checked" disabled ></li>';
                        }
                    }
                });
            }
            $("#tableFilter").prepend(_html);
        }
        this.filterEvent = function () {
            $('.glyphicon-filter').click(function (e) {
                $("#tableFilter").toggle();
            });
            $('button[name=filterBtn]').click(function () {
                //如果没有渲染table body 则初始化header，否则click query
                if ($('.treable-body').length == 0) {
                    $("#tableFilter").toggle();
                    _this.renderTable([]);
                } else {
                    _this.getFilterHeader();
                    $("#tableFilter").toggle();
                    $("button.btn-query").trigger("click");
                }
            });
        }
        this.render = function () {
            _this.renderTable([]);
        }
        this.event = function () {
            _this._DOM.off('MISSION_COMPLETE', _this.adManageTable).on('MISSION_COMPLETE', _this.adManageTable, $.proxy(this.missionComplete, this));
            _this._DOM.off('SORT_CLICK', _this.adManageTable).on('SORT_CLICK', _this.adManageTable, $.proxy(this.sortClick, this));
            _this._DOM.off('TOOLBAR_CLICK', _this.adManageTable).on('TOOLBAR_CLICK', _this.adManageTable, $.proxy(this.toolbarClick, this));
            _this._DOM.off('STATUS_UPDATE', '.sutable-col-status>.switcher>label>input').on('STATUS_UPDATE', '.sutable-col-status>.switcher>label>input', $.proxy(this.statusChange, this));
            _this._DOM.off('RESIZE_DONE', _this.adManageTable).on('RESIZE_DONE', _this.adManageTable, $.proxy(this.resizeTable, this));
            _this._DOM.off('DROPDOWN_MENU_MONEY_SHOW', 'i.font-icon-money').on('DROPDOWN_MENU_MONEY_SHOW', 'i.font-icon-money', $.proxy(this.dropdownMenuMoneyShow, this));
            $(window).on('menu-fold', $.proxy(_this.adjustTableFooter, _this));
        }


        /**
         * { 查询,渲染 }
         *
         * @method     query
         * @param      {<type>}  params  { description }
         */
        this.query = function (params) {
            queryParams = params;

            admanageModel.groupbyadset(params, function (result) {
                _this.renderTable(result, params);
                $(_this._DOM).trigger("adManageTable-result", {data: result});
                setTimeout(function () {
                    //保持上一次的状态
                    $('.table-control .table-fold.open').trigger('click');

                    //如果有,则关闭
                    $('#alert-holder .close').trigger('click');
                }, 200);
            });
        }

        this.renderTable = function (result, params) {
            _this._DOM.find(".ndp-treable-wrapper").empty();
            this.$adManageTable = _this._DOM.find(".ndp-treable-wrapper").treable({
                head: _this.getFilterHeader(header),
                body: result.newData,
                tail: [{text: 1000}, {text: 1000}, {text: 1000}, {text: 1000}, {text: 1000}, {text: 1000}, {text: 1000}, {text: 1000}, {text: 1000}, {text: 1000}],
                sort: _this.getInitSortNums(), //base from 0
                todata: [
                    {name: I18N.getText('management', 'adjustBudgetPrice'), id: "adjust-price", class: 'adjust-price'},
                    {name: I18N.getText('management', 'editAdset'), id: "edit-ad", class: 'edit-ad'},
                    {name: I18N.getText('management', 'chart'), id: "open-adchart", class: 'open-adchart'},
                    {name: I18N.getText('management', 'subdivideData'), id: "subdivide-data", class: 'subdivide-data'},
                    {name: I18N.getText('management', 'editAd'), id: "edit-innovate", class: 'edit-innovate'}
                ],
                tabs: [
                    {id: "0", name: 'Purchase & CPC', type: "line"},
                    {id: "0", name: "ROI & SalesAmount", type: "line"}
                ],
                scrollDOM: $(".fmp-article")
            });
            this.renderStatus();
            this.renderTableFooter(result);
            this.resizeTable();
            this.renderTableTools();
            this.renderTableSort(params);
            this.eventHorizScroll();
            this.event();
        }

        /**
         * { status状态是否可以修改 }
         *
         * @method     renderStatus
         */
        this.renderStatus = function () {
            _this._DOM.find('.sutable-col-status[value="DELETED"],.sutable-col-status[value="ARCHIVED"]').find('.switcher').addClass('disabled')
        }

        /**
         * 底部的统计数据
         * @param result
         */
        this.renderTableFooter = function (result) {
            // var tableHeaderHtml = _this._DOM.find('.treable-header').html();

            var $footer = _this._DOM.find(".ndp-treable-wrapper .treable-footer");
            if (result && result.summary) {
                var footerHtml = '';
                var adset = I18N.getText('management', 'adsets') + ' : ' + result.summary.adSetCount;
                footerHtml = footerHtml + '<span>' + adset + '</span> &nbsp;&nbsp;&nbsp;&nbsp;';
                var ad = I18N.getText('management', 'ads') + ' : ' + result.summary.adCount;
                footerHtml = footerHtml + '<span>' + ad + '</span> &nbsp;&nbsp;&nbsp;&nbsp;';
                if ((result.summary.spent + '').length > 0) { //成本
                    footerHtml = footerHtml + '<span>' + I18N.getText('management', 'spentWithFlag') + (' $ ' + kit.cent_to_dollar(result.summary.spent)) + '</span> &nbsp;&nbsp;&nbsp;&nbsp;';
                }
                if ((result.summary.cpc + '').length > 0) { //花费
                    footerHtml = footerHtml + '<span>' + I18N.getText('management', 'costWithFlag') + (' $ ' + kit.cent_to_dollar(result.summary.cpc)) + '</span> &nbsp;&nbsp;&nbsp;&nbsp;';
                }
                $footer.html('<li style="padding-top: 15px;padding-left: 20px;">' + footerHtml + '</li>');
                $footer.show();
            } else {
                $footer.hide();
            }
        }

        /**
         * { 将 sutable-toolbar 移动到 monitor-control }
         *
         * @method     renderTableTools
         */
        this.renderTableTools = function () {

            var $toolbar = _this._DOM.find('.sutable-toolbar');
            $toolbar.remove();
            return;
        }

        /**
         * { 横向滚动条事件 }
         *
         * @method     eventHorizScroll
         */
        this.eventHorizScroll = function () {
            _this._DOM.find('.horiz-scroll').mousedown(function () {
                $('.fmp-article').css('overflow', 'hidden');
            }).mouseleave(function () {
                $('.fmp-article').css('overflow', 'auto')
            })
        }


        /**
         * { 设置头部排序 }
         *
         * @method     renderTableSort
         */
        this.renderTableSort = function (params) {
            if (!params) {
                return;
            }
            var _header = [],sortCol = 0;
            var localHeader = window.localStorage.getItem("tableHeader");
            if(localHeader != null){
                _header = localHeader.split(",");
                var index = $.inArray(params.sort.field,_header);
                if(index == -1){ // 查询列中没有的那几项（createdUtcTime,spent,）
                    sortCol = 0
                }else{
                    sortCol = index + 1;
                }
            }
            if(sortCol != 0){
                //默认 使用创建时间（createdUtcTime）排序,如果这个时间列没有的话，则不排序
                var $col = _this.$adManageTable.find('.treable-header .sutable-col[col="' + sortCol + '"]');
                $col.find('.hi').removeClass('hi');
                var hi = params.sort.type == 1 ? '.glyphicon-triangle-top' : '.glyphicon-triangle-bottom';
                $col.addClass('sort').find(hi).addClass('hi');
            }
        }


        /**
         * { 调整滚动条 }
         *
         * @method     resizeTable
         */
        this.resizeTable = function () {
            $('.treable-footer').width($('.ndp-treable-wrapper').width());
            $('.horiz-scroll').width($('.ndp-treable-wrapper').width());
        }

        /**
         * { 调整sutable-footer }
         *
         * @method     adjustTableFooter
         */
        this.adjustTableFooter = function () {
            setTimeout(function () {
                //_this._DOM.find(".ndp-treable-wrapper .sutable-footer").width($('.fmp-monitor').width());
            }, 500);
        }

        this.missionComplete = function (e) {
            console.log(arguments);

        }

        this.sortClick = function (e) {
            var localHeader = window.localStorage.getItem("tableHeader");
            var headerArr = localHeader.split(",");
            var d = e.originalEvent.data;
            console.log("正在排序的列为：" + headerArr[d.col-1]);
            var parmas = {
                field: headerArr[d.col-1],
                type: d.sort == 'up' ? 1 : -1
            }
            _this.sortCol = d.col; //排序的索引和方向,为了渲染使用
            _this.sortType = d.sort;
            //如果排序,将初始值改为1
            $('.ndp-page-wrapper .pagination .page-item.active').removeClass('active');
            $(_this._DOM).trigger("adManageTable-sort", {data: parmas});
        }


        this.toolbarClick = function (e) {
            if (e && e.originalEvent && e.originalEvent.data && e.originalEvent.data.dataID) {
                var d = e.originalEvent.data;
                var id = d.dataID;
                if (d.id == 'adjust-price') {
                    _this.adjustPrice(id);
                } else if (d.id == 'edit-ad') {
                    _this.editAd(id);
                } else if (d.id == 'open-adchart') {
                    _this.openAdchart(id);
                } else if (d.id == 'edit-innovate') {
                    _this.editInnovate(id);
                } else if (d.id == 'subdivide-data') {
                    _this.subdivideData(id);
                }
            }
        }

        this.statusChange = function (e) {
            var $id = $(e.target).closest('li[data-id][deep=2]'); //[deep=2] 表示是 ad,首先取ad,如果ad不存在,则表示此事件是发生在adset上面
            var type = 'ad';
            if ($id.length == 0) {
                $id = $(e.target).closest('li[data-id][deep=1]'); // [deep=1] 表示是 adset
                type = 'adset';
            }
            var status = !$(e.target).parent().hasClass('active'); //是否打开,因为此时已经把状态改变,需要取反
            var idArr = $id.data('id').split('-');
            if (type == 'ad') {
                var params = {
                    "ad_id": idArr[1], // 广告ID（必须项）
                    "job_type": "update_ad_run_status", //更新操作类型
                    "value": (status ? 'PAUSED' : 'ACTIVE') // 修改后的值
                }
                admanageModel.updateAd(params, function (result) {
                    _this.queryStatus(result, 1, _this.refreshPageCallback, _this.statusChangeFailCallback);
                });
            } else {
                var params = {
                    "adSet_id": idArr[1], // 广告ID（必须项）
                    "job_type": "update_ad_set_run_status", //更新操作类型
                    "value": (status ? 'PAUSED' : 'ACTIVE') // 修改后的值
                }
                admanageModel.updateAdSet(params, function (result) {
                    _this.queryStatus(result, 1, _this.refreshPageCallback, _this.statusChangeFailCallback);
                });
            }

        }

        /**
         * { 更新adset/ad状态失败后的回调 }
         *
         * @method     statusChangeFailCallback
         * @param      {<type>}  result  { description }
         */
        this.statusChangeFailCallback = function (result) {
            kit.alert2(I18N.getText('management', 'updateFail'));
            var id = result.param.ad_id ? result.param.ad_id : result.param.adSet_id;
            var deep = result.param.ad_id ? 2 : 1;
            var $status = $('[data-id$=' + id + '] [deep=' + deep + '] .sutable-col-status .switcher>label');
            var $checkedStatus = $status.find('.scheckbox');
            $status.toggleClass('active');
            $checkedStatus.prop('checked', !$checkedStatus.prop('checked'));
        }


        /**
         * { 更新各种数据之后,将当前页面重新刷新一次 }
         *
         * @method     refreshPageCallback
         */
        this.refreshPageCallback = function (result) {
            console.info(result);
            kit.alert_success(I18N.getText('management', 'updateSuccess'));
            $('.ndp-page-wrapper .page-item.active').trigger('click'); //点击当前分页
        }


        /**
         * { 查询job状态 }
         *
         * @method     queryStatus
         * @param      {<type>}                    jobId         { jobId }
         * @param      {(Function|number|string)}  progress      { 进度条 }
         * @param      {<type>}                    okCallback    { 更新成功后的回调 }
         * @param      {<type>}                    failCallback  { 更新失败后的回调 }
         */
        this.queryStatus = function (jobId, progress, okCallback, failCallback) {
            var params = {
                job_id: jobId.job_id
            }
            if (progress >= 99) {
                progress = 99;
            }
            if (progress == 1) {
                showAlert({
                    content: '<h4>' + I18N.getText('management', 'synchronizing') + '</h4><div class="progressbar-default" name="line"></div>'
                });
                //删除ok按钮
                $('#alert-holder button.btn.btn-default').remove();

                $('#alert-holder [data-dismiss="modal"]').off('click').on('click', function () {
                    $('#alert-holder').modal('hide');
                    $('#alert-holder').hide();
                    clearTimeout(_this.setTimeoutId);
                });
            }
            $('.progressbar-default').progressbar({
                css: 'progressbar-test-style',
                progress: progress + '%',
                shape: 'default',
                width: 568,
                size: 5
            });
            $('.progressbar-default').progressbar('progress', progress + '%');

            admanageModel.getJob(params, function (result) {
                if (result.job_status == 'fail' || result.job_status == 'success') {
                    $('#alert-holder').modal('hide');
                    $('#alert-holder .close').trigger('click')
                    setTimeout(function () {
                        $('#alert-holder').modal('hide');
                        $('#alert-holder .close').trigger('click')

                        if (result.job_status == 'fail') {
                            //console.info(result)
                            if (result.result) { //将错误信息也打印出来.
                                try {
                                    var errorJson = null;
                                    var msg = '';
                                    if (typeof(result.result) == 'string') {
                                        errorJson = JSON.parse(result.result).error;
                                    } else if (result.result.error) {
                                        errorJson = result.result.error;
                                    } else {
                                        console.info('无法解析的错误!')
                                        return;
                                    }
                                    //if (errorJson.message) {
                                    //    msg = msg + errorJson.message + '<br>';
                                    //}

                                    if (errorJson.error_user_msg) {
                                        msg = msg + errorJson.error_user_msg + '<br>';
                                    }

                                    //if (errorJson.error_user_title) {
                                    //    msg = msg + errorJson.error_user_title + '<br>';
                                    //}
                                    if (msg.length > 0) {
                                        showTip({
                                            bind: $(".fmp-article"),
                                            time: 10,
                                            through: true,
                                            type: "danger",
                                            content: msg.substr(0, 500),
                                            icon: "<i class='font-icon font-icon-error'></i>",
                                            close: true
                                        });
                                    }
                                } catch (e) {
                                    showTip({
                                        bind: $(".fmp-article"),
                                        time: 10,
                                        through: true,
                                        type: "danger",
                                        content: result.result.substr(0, 500),
                                        icon: "<i class='font-icon font-icon-error'></i>",
                                        close: true
                                    });

                                }
                            } else {
                                showTip({
                                    bind: $(".fmp-article"),
                                    time: 10,
                                    through: true,
                                    type: "danger",
                                    content: I18N.getText('management', 'updateFail'),
                                    icon: "<i class='font-icon font-icon-error'></i>",
                                    close: true
                                });
                            }

                            if (failCallback) {
                                failCallback(result);
                            }
                        } else if (result.job_status == 'success') {
                            if (okCallback) {
                                okCallback(result);
                                setTimeout(function () {
                                    $('#alert-holder').modal('hide');
                                    $('#alert-holder .close').trigger('click')
                                    _this.refreshPageCallback(result);
                                }, 200);
                            } else {
                                kit.alert_success(I18N.getText('management', 'updateSuccess'));
                            }
                        }


                    }, 50);

                } else {
                    clearTimeout(_this.setTimeoutId);
                    _this.setTimeoutId = setTimeout(function () {
                        progress = (progress + parseInt(Math.random() * 20));
                        _this.queryStatus(jobId, progress, okCallback, failCallback);
                    }, 2000);
                }
            });
        }


        /**
         * { 调整预算价格 }
         *
         * @method     adjustPrice
         * @param      {<type>}  e       { description }
         */
        this.adjustPrice = function (id) {
            var adsetId = id.split('-')[1];
            new AdjustPrice().init(adsetId, _this.queryStatus);
        }

        /**
         * { 编辑广告 }
         *
         * @method     editAd
         * @param      {<type>}  e       { description }
         */
        this.editAd = function (id) {
            var adId = id.split('-')[1];
            new EditAd().init(adId, _this.queryStatus);
        }

        /**
         * { 查看图表 }
         *
         * @method     openAdchart
         * @param      {<type>}  e       { description }
         */
        this.openAdchart = function (id) {
            var type = id.split('-')[0];
            var adsetId = id.split('-')[1];
            var $chartWrapper = $('.chart-wrapper[data-id="' + id + '"]');
            $chartWrapper.closest('li.treable-item[data-id^="adset"]').addClass('open');
            setTimeout(function () {
                $('.chart-wrapper').find("div[role='tabpanel']").empty();
                $('.chart-wrapper').removeClass('open');
                $chartWrapper.addClass('open');
                $(".fmp-article").trigger("scroll");
                //console.log("----传入趋势图的adsetId---" + adsetId);
                new OpenAdchart().init(adsetId, $chartWrapper, _this.$adManageTable);

            }, 200);

        }

        this.subdivideData = function (id) {
            new SubdivideData().init(id);
        }
        /**
         * { 修改创意 }
         *
         * @method     editInnovate
         * @param      {<type>}  e       { description }
         */
        this.editInnovate = function (id) {
            var adId = id.split('-')[1];
            var editInnovate = new EditInnovate();
            console.info(editInnovate);
            editInnovate.init(adId, queryParams.fbConnectionObjectId, queryParams.fbConnectionObjectName, queryParams.iconUrl, _this.queryStatus);
        }

        this.foldTable = function (open) {
            this.$adManageTable.fold(open);
        }


        this.updateStatus = function (arguments) {
            console.log(arguments)
            console.log($(e.currentTarget))
        }

        /**
         * { 下拉money菜单显示 }
         *
         * @method     dropdownMenuMoneyShow
         * @param      {<type>}  e       { description }
         */
        this.dropdownMenuMoneyShow = function (e, target) {
            console.info($(e.currentTarget))
            //展开 toolbar
            var dataId = $(e.currentTarget).closest('.treable-item[data-id]').attr('data-id');
            var statusValue = $(e.currentTarget).parent().prev().attr('value'); //状态
            var disabledFlag = statusValue == 'DELETED' || statusValue == 'ARCHIVED'; //如果是删除或者归档状态不允许编辑
            if (dataId && dataId.indexOf('-') > -1) {
                var type = dataId.split('-')[0];
                var $dom = target.dom;
                $dom.find('li').hide();
                if (type == 'adset') { //编辑广告组  看图表
                    // $dom.find('li[data-id=edit-ad]').toggleClass('disabled', disabledFlag).show();
                    $dom.find('li[data-id=open-adchart]').show();
                    $dom.find('li[data-id=adjust-price]').toggleClass('disabled', disabledFlag).show();
                } else { // 编辑广告  看图表 调整预算
                    // $dom.find('li[data-id=edit-innovate]').toggleClass('disabled', disabledFlag).show();
                    $dom.find('li[data-id=open-adchart]').show();
                }
                $dom.find('li[data-id=subdivide-data]').show();
            }


        }


        /***
         ** 响应事件变化
         **/
        this.update = function (msg) {
            switch (msg.type) {
                case "shrink_complete": // 菜单收缩动作完成
                case "expand_complete": //菜单展开动作完成
                    if (tre) tre.resize(); //调用 列表插件的方法 resize 重新修正列表的宽度
                    break;
            }
            _super.update.call(_this, msg);
        }
    }

    return new Main();
});
